Task: Generate custom AMR reports
Stratifying by: Hospital, directorate, ward, age, etc.
Timeframe/frequency: Every quarter
Jadey N Ryan gave an excellent talk on creating parameterised reports at this year’s posit::conf(2023)
Megan Hall wrote an excellent blog post on creating parameterised reports (2022)
Producing parameterised reports using the {nycflights13} dataset
For each parameter, wrangle dataset into “params” after loading required packages and raw data before any additional data wrangling steps.
library(nycflights13) # load packages and data
flights <- nycflights13::flights
if (!is.na(params$origin) && params$origin != "NA") { # Param for nycflights13::flights$origin
flights <- flights[flights$origin == params$origin, ]
}
if (nrow(flights) == 0) {
stop("Invalid selection. Did you misspell `origin`?")
}
not_cancelled <- flights |> # undertake additional wrangling steps
filter(!is.na(arr_delay), !is.na(dep_delay))
---
Report content goes here. # Write contentStrengthen the narrative of your report by including executable expressions within markdown using `r `.
For example, we can use inline code to state the number of observations in our data.
There are 336776 observations in our data.
Manually change the parameter values in the header YAML of your .qmd file and hit Render.
Use the terminal to specify the parameter(s) you want to use.
Leverage the quarto::quarto_render() function in R to automatically create reports for each parameter subcategory and name each file as specified.
runparams <- function(origin) { # create function
quarto::quarto_render(
"parameterised_report.qmd", # Specify .qmd file name
output_format = "html", # Specify output format
execute_params = list(origin = origin), # Specify parameter of interest
output_file = glue::glue("report_{origin}.html") # Specify (parameterised) file name
)
}
runparams(origin = "JFK") # code to run a single report using function
params_origin <- unique(flights$origin) # Or execute code with purrr:map() function
purrr::map(params_origin, runparams)Aim
To model predicted drug resistance rates using the AMR package for R.
Methods
The LIMS was interrogated to collect data on all culture-positive blood cultures collected between 01 April 2019 and 31 July 2023 .
The AMR package [1,2] is a free, open-source and independent package for R [3] that provides a standard for clean and reproducible analysis and prediction of Antimicrobial Resistance (AMR).
Helps to: cleverly de-duplicate data; calculate and visualise historical AMR rates; and predict future AMR rates using regression models.
Since Q1 2019:
11967 distinct positive blood cultures
Collected from 7435 distinct patients
Leading to isolation of 13227 organisms
| Characteristic | 90-day survival (95% CI) | 180-day survival (95% CI) | 365-day survival (95% CI) |
|---|---|---|---|
| Overall | 88% (87%, 89%) | 86% (85%, 87%) | 84% (83%, 85%) |
| Gram stain result | |||
| Gram-negative | 87% (86%, 88%) | 84% (83%, 86%) | 82% (81%, 84%) |
| Gram-positive | 89% (88%, 90%) | 88% (87%, 89%) | 85% (84%, 86%) |
| Organism isolated | |||
| E. coli | 88% (86%, 90%) | 86% (84%, 88%) | 84% (82%, 86%) |
| K. pneumoniae | 85% (82%, 88%) | 82% (79%, 86%) | 79% (75%, 83%) |
| Other | 89% (88%, 90%) | 87% (86%, 88%) | 85% (84%, 86%) |
| P. aeruginosa | 83% (77%, 89%) | 80% (74%, 86%) | 79% (74%, 86%) |
| S. aureus | 85% (82%, 88%) | 83% (80%, 87%) | 81% (77%, 84%) |
Informs clinical decision-making
Helps target (limited) infection prevention and control resources
Assists with updating of antimicrobial guidelines
Helps justify investment in antimicrobial stewardship
Daniel Weiand, Consultant medical microbiologist
Newcastle upon Tyne Hospitals NHS Foundation Trust
Email: dweiand@nhs.net
NHS-R community blog: https://nhsrcommunity.com/author/daniel-weiand/